package edu.hbsi.demo2;

public class House {
    // 定义变量
    private double length;
    private double width;
    private String structure;

    // 无参构造方法，对变量进行初始化
    public House() {
        this.length = 10.0; // 假设默认值
        this.width = 10.0;  // 假设默认值
        this.structure = "砖混结构"; // 假设默认结构
    }

    // 三个参数的构造方法
    public House(double length, double width, String structure) {
        this.length = length;
        this.width = width;
        this.structure = structure;
    }

    // keepWarm方法，输出“保暖”
    public void keepWarm() {
        System.out.println("保暖");
    }


    public double preventNoise(int factor1, int factor2) {

        return factor1 + factor2;
    }


    @Override
    public String toString() {
        return "House{" +
                "length=" + length +
                ", width=" + width +
                ", structure='" + structure + '\'' +
                '}';
    }


    public static void main(String[] args) {

        House house1 = new House();
        System.out.println(house1);
        house1.keepWarm();


        House house2 = new House(20.0, 15.0, "钢结构");
        System.out.println(house2);
        System.out.println("噪音值：" + house2.preventNoise(5, 10));
    }
}
